package everything;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class HumanAgent extends Agent {

	public HumanAgent(String name, String color, int x, int y, WorldMap map, int id) {
		super(name, color, x, y, map, id);
		_type = "human";
	}

	@Override
	public void makeMove() {
		try {
			BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			//TODO make reading not waiting to ENTER
			int input = in.read();	//TODO input checking
			System.out.println("Location: x = " + _xLocation + " y = " + _yLocation);
			switch (input){
			case '8':
				if(_map.isMovementBlocked(_xLocation - 1, _yLocation))
					setOrientation("NORTH");
				else move("NORTH");
				break;
			case '2':
				if(_map.isMovementBlocked(_xLocation + 1, _yLocation))
					setOrientation("SOUTH");
				else move("SOUTH");
				break;
			case '4':
				if(_map.isMovementBlocked(_xLocation , _yLocation - 1))
					setOrientation("WEST");
				else move("WEST");
				break;
			case '6':
				if(_map.isMovementBlocked(_xLocation , _yLocation + 1))
					setOrientation("EAST");
				else move("EAST");
				break;
			case '5':
				move("Fire");
				//_map.tryToKill(this);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
